package com.citywy.boot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;

/**
 * 主程序类
 * SpringBootApplication注解：这是一个springboot应用
 */
@SpringBootApplication
//@SpringBootConfiguration
//@EnableAutoConfiguration
//@ComponentScan("com.citywy.boot")
public class MainApplication {
    public static void main(String[] args) {
        //返回IOC容器
        ConfigurableApplicationContext run = SpringApplication.run(MainApplication.class,args);
        //查看容器中的组件
        String [] names = run.getBeanDefinitionNames();
        for(String name:names){
            System.out.println(name);
        }

//        User user03 = run.getBean("user",User.class);
//        User user04 = run.getBean("user",User.class);
//        Pet tomcat = run.getBean("tom", Pet.class);
//        System.out.println(user03==user04);

//        boolean hasuser = run.containsBean("user");
//        System.out.println(hasuser);
//
//        boolean hasuser1 = run.containsBean("buser1");
//        System.out.println(hasuser1);
//
//        boolean haspet2 = run.containsBean("bpet1");
//        System.out.println(haspet2);

    }
}
